﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameDefine : MonoBehaviour
{
	public GameObject cardPrefap;
	public static GameDefine instance;

	public List<CardModule> listCard;
	public List<GameObject> listMonsterPrefap;
	public Sprite sprLevelButtonLock, sprLevelButtonOpen, sprLevelButtonBossLock, sprLevelButtonBossOpen;
	public Sprite sprSoundOn, sprSoundOff, sprMusicOn, sprMusicOff;

	void Awake ()
	{
		DontDestroyOnLoad (gameObject);
		instance = this;
		LoadingControl.LoadCardData ();
		LoadingControl.LoadLevelsData ();
		LoadingControl.LoadMonsterData ();
		GameManager.LoadSaveData ();
	}



	public GameObject changeIconPrefap;
	// Use this for initialization
	public List<CardType> listCardTypeCreate = new List<CardType> () {
		CardType.ARROW_1,
		CardType.ARROW_2,
		CardType.ARROW_3,
		CardType.HP,
		CardType.MAGIC_1,
		CardType.MAGIC_2,
		CardType.MAGIC_3,
		CardType.SHIELD,
		CardType.SWORD_1,
		CardType.SWORD_2,
		CardType.SWORD_3,
		CardType.SWORD_ARROW_MAGIC,
		CardType.ARROW_1,
		CardType.ARROW_2,
		CardType.ARROW_3,
		CardType.HP,
		CardType.MAGIC_1,
		CardType.MAGIC_2,
		CardType.MAGIC_3,
		CardType.SHIELD,
		CardType.SWORD_1,
		CardType.SWORD_2,
		CardType.SWORD_3,
		CardType.SWORD_ARROW_MAGIC,
		CardType.X2
	};

	void Start ()
	{
		AudioManager.instance.SetSoundStatus (GameManager.dataSave.isSoundOn);
		AudioManager.instance.SetMusicStatus (GameManager.dataSave.isMusicOn);
		AudioManager.instance.PlayMusic (AudioClipType.overture);
	}

	public CardModule GetCardModuleByType (CardType type)
	{
		for (int i = 0; i < listCard.Count; i++) {
			CardModule card = listCard [i];
			if (card.type == type) {
				return card;
			}
		}
		return null;
	}

	public GameObject GetMonsterPrefapByName (string name)
	{
		for (int i = 0; i < listMonsterPrefap.Count; i++) {
			
			if (listMonsterPrefap [i].name == name) {
				return listMonsterPrefap [i];
			}
		}
		return null;
	}
	// Update is called once per frame
}

[System.Serializable]
public class CardModule
{
	public CardType type;
	public Sprite sprite;
	public int value;
}

[System.Serializable]
public enum CardType
{
	X2,
	SHIELD,
	HP,
	SWORD_1,
	SWORD_2,
	SWORD_3,
	ARROW_1,
	ARROW_2,
	ARROW_3,
	MAGIC_1,
	MAGIC_2,
	MAGIC_3,
	SWORD_ARROW_MAGIC,
	ICE,
	DIRTY,
	RED

}